/*
Spotter Exercise Manager
Copyright 2011 Evan Nelson.

This file is part of Spotter Exercise Manager.

Spotter Exercise Manager is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Spotter Exercise Manager is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Spotter Exercise Manager.  If not, see <http://www.gnu.org/licenses/>.

The author can be contacted by emailing ean5533@gmail.com
*/

#include <QApplication>
#include <QDesktopWidget>
#include <QRect>
#include "login.h"
#include "ui_login.h"

#include "database.h"

Login::Login(QWidget *parent)
    : QDialog(parent), ui(new Ui::LoginClass)
{
    ui->setupUi(this);

    centerWidgetOnScreen(this);
}

Login::~Login() {
    delete ui;
}

void Login::centerWidgetOnScreen(QWidget* widget) {
     QRect rect = QApplication::desktop()->availableGeometry(widget);
     widget->move(rect.center() - widget->rect().center());
}

void Login::on_buttonBox_accepted()
{
    this->done(ui->spinBox->value());
}

void Login::on_buttonBox_rejected()
{
    this->done(-1);
}
